﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TiposComuns.Excepcoes;

namespace TiposComuns.Objectos
{
    /// <summary>
    /// User profile
    /// </summary>
    [Serializable]
    public class Profile
    {
        #region Attributes
        private List<string> interesses;        //List of interests
        #endregion

        #region Constructors
        public Profile()
        {
            interesses = new List<string>();
        }
        

        public Profile(string username,bool genero,List<string> interesses,
            int idade)
        {
            this.Username = username;
            this.Genero = genero;
            if (interesses.Count() > 5)
                throw new InterestOverflowException("Número de interesses superior a 5");
            this.interesses = interesses;
            this.Idade = idade;
        }
        #endregion

        #region Modifiers
        /// <summary>
        /// Username
        /// </summary>
        public string Username
        {
            get;
            set;
        }

        /// <summary>
        /// Gender:
        /// -True = Male
        /// -False = Female
        /// </summary>
        public bool Genero
        {
            get;
            set;
        }

        /// <summary>
        /// Age
        /// </summary>
        public int Idade
        {
            get;
            set;
        }

        #endregion

        #region Methods
        /// <summary>
        /// List of interests. Cannot have more than 5 entries.
        /// </summary>
        public List<string> Interesses
        {
            get { return interesses; }
            set
            {
                if (value.Count() > 5)
                    throw new InterestOverflowException("Número de interesses superior a 5");
                this.interesses = value;
            }
        }

        public Profile Clone()
        {
            Profile prof = new Profile(this.Username, this.Genero, new List<string>(),this.Idade);
            foreach (string inter in this.interesses)
                prof.interesses.Add(inter);

            return prof;
        }

        #endregion
    }
}
